/*
* 构件详情
* */
import 'dart:convert';

import 'package:center_beijing/api/component_api.dart';
import 'package:center_beijing/api/product_api.dart';
import 'package:center_beijing/common/QRScan.dart';
import 'package:center_beijing/common/custom_floatingAction_buttonLocation.dart';
import 'package:center_beijing/common/logutil.dart';
import 'package:center_beijing/common/notification.dart';
import 'package:center_beijing/common/styles.dart';
import 'package:center_beijing/common/utils.dart';
import 'package:center_beijing/config/global_config.dart';
import 'package:center_beijing/config/routeConfig.dart';
import 'package:center_beijing/models/GetxControllerOne.dart';
import 'package:center_beijing/widgets/custom_loading_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:tab_indicator_styler/tab_indicator_styler.dart';

class ProductionDetail extends StatefulWidget {
  @override
  _ProductionDetailState createState() => _ProductionDetailState();
}

class _ProductionDetailState extends State<ProductionDetail>
    with SingleTickerProviderStateMixin {
  GetXControllerOne controller = Get.put(GetXControllerOne());
  List dataSource = [];
  List BOMList = [];
  CustomLoading loading = CustomLoading.withMessage('请稍候...');
  var compId = Get.arguments;
  var compDetail = Map();
  TabController _tabController;
  int currentIndex = 0;
  final List<Tab> myTabs = <Tab>[
    Tab(text: '生产记录'),
    Tab(text: 'BOM清单'),
  ];

  @override
  void initState() {
    super.initState();
    this.getAllInfo();
    bus.on('refreshDetail', (arg) {
      this.getAllInfo();
    });
  }

  getAllInfo() {
    loading.show(delay: 30);
    Future.wait([this.getCompDetail(), getCompProHistory(), getBOMs()])
        .then((results) {
      loading.dismiss();
      if (results[0] != null) {
        this.setState(() {
          compDetail = results[0];
          controller.updateDetail(results[0]);
        });
      }
      if (results[1] != null && results[1].length > 0) {
        this.setState(() {
          dataSource = results[1].reversed.toList();
          controller.updateDataSource(dataSource);
        });
      }
      if (results[2] != null && results[2]['data'].length > 0) {
        this.setState(() {
          BOMList = results[2]['data'];
        });
      }

      this.setState(() {});
    });
  }

  /*
  * 获取构件详情
  * */
  Future getCompDetail() async {
    var result = await getComponentDetail(compId);
    return result;
  }

  /*
  * 获取构件生产记录
  * */
  Future getCompProHistory() async {
    var result = await getCompHistory(compId);
    return result;
  }

  /*
  * 获取BOM清单
  * */
  Future getBOMs() async {
    var pass = {'componentId': compId, 'page': 1, 'page-size': 200};
    var result = await getBOMList(pass);
    return result;
  }

  @override
  void dispose() {
    bus.off('refreshDetail');
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('构件详情'),
      ),
      body: Container(
        color: Styles.MainBackgroundColor,
        padding:
            EdgeInsets.fromLTRB(0, 0, 0, MediaQuery.of(context).padding.bottom),
        child: Column(
          children: [
            Expanded(
              child: SingleChildScrollView(
                child: Column(
                  children: [
                    Container(
                      padding: EdgeInsets.fromLTRB(Styles.spacing16,
                          Styles.spacing8, Styles.spacing16, Styles.spacing8),
                      child: Column(
                        children: [
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.White70,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '订单名称',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    (compDetail['orderInfo'] != null &&
                                            compDetail['orderInfo']
                                                    ['orderName'] !=
                                                null)
                                        ? compDetail['orderInfo']['orderName']
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.GranColor,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '构件类型',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    (compDetail['compKind'] != null &&
                                            compDetail['compKind']
                                                    ['compKindName'] !=
                                                null)
                                        ? compDetail['compKind']['compKindName']
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.White70,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '构件编号',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    compDetail['code'] != null
                                        ? compDetail['code']
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.GranColor,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '设计配合比',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    compDetail['designMixProportion'] != null
                                        ? compDetail['designMixProportion']
                                            ['name']
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.White70,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '实际配合比',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    compDetail['mixProportion'] != null
                                        ? compDetail['mixProportion']['name']
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.GranColor,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '混凝土设计用量',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    compDetail['designConcreteUsage'] != null
                                        ? compDetail['designConcreteUsage']
                                            .toString()
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.White70,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '混凝土实际用量',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    compDetail['concreteUsage'] != null
                                        ? compDetail['concreteUsage'].toString()
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.GranColor,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '方量(m³)',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    compDetail['volume'] != null
                                        ? compDetail['volume'].toString()
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.White70,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '重量(T)',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    compDetail['weight'] != null
                                        ? compDetail['weight'].toString()
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.GranColor,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '砼标号',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    compDetail['concreteGrade'] != null
                                        ? compDetail['concreteGrade']
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.White70,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '尺寸-长(mm)',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    compDetail['length'] != null
                                        ? compDetail['length'].toString()
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.GranColor,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '尺寸-宽(mm)',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    compDetail['width'] != null
                                        ? compDetail['width'].toString()
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.White70,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '尺寸-高(mm)',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    compDetail['height'] != null
                                        ? compDetail['height'].toString()
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4,
                                Styles.spacing4),
                            color: Styles.GranColor,
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Text(
                                      '所在位置',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont),
                                    )),
                                Expanded(
                                  flex: 2,
                                  child: Text(
                                    compDetail['levelPath'] != null
                                        ? (compDetail['levelPath']
                                                .split('&_&_&'))
                                            .join('/')
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.NormalFont),
                                  ),
                                )
                              ],
                            ),
                          ),
                        ],
                      ),
                    ),
                    Container(
                      height: 40.h,
                      color: Colors.white,
                      child: DefaultTabController(
                        length: 2,
                        initialIndex: currentIndex,
                        child: TabBar(
                          controller: _tabController,
                          onTap: (value) {
                            this.setState(() {
                              currentIndex = value;
                            });
                          },
                          indicatorColor: Colors.red,
                          tabs: myTabs,
                          labelColor: Styles.BlueColor,
                          unselectedLabelColor: Styles.LeftTitleColor,
                          // add it here
                          indicator: MaterialIndicator(
                              color: Styles.BlueColor, height: 1),
                        ),
                      ),
                    ),
                    currentIndex == 0
                        ? Column(
                            children: [
                              Container(
                                padding: EdgeInsets.fromLTRB(
                                    Styles.spacing16,
                                    Styles.spacing8,
                                    Styles.spacing16,
                                    Styles.spacing8),
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Row(
                                      children: [
                                        Image.asset(
                                          'assets/images/document.png',
                                          width: 14.w,
                                          height: 14.w,
                                          fit: BoxFit.contain,
                                        ),
                                        Text(
                                          '生产记录清单',
                                          style: TextStyle(
                                              color: Styles.DetailColor,
                                              fontSize: Styles.NormalFont),
                                        )
                                      ],
                                    ),
                                    RichText(
                                        text: TextSpan(children: [
                                      TextSpan(
                                        text: '共',
                                        style: TextStyle(
                                            fontSize: Styles.NormalFont,
                                            color: Styles.LeftTitleColor),
                                      ),
                                      TextSpan(
                                        text: this.dataSource.length.toString(),
                                        style: TextStyle(
                                            fontSize: Styles.NormalFont,
                                            color: Styles.BlueColor),
                                      ),
                                      TextSpan(
                                        text: '条记录',
                                        style: TextStyle(
                                            fontSize: Styles.NormalFont,
                                            color: Styles.LeftTitleColor),
                                      )
                                    ]))
                                  ],
                                ),
                              ),
                              Container(
                                child: Column(
                                  children:
                                      this.dataSource.asMap().keys.map((index) {
                                    return Container(
                                      padding: EdgeInsets.fromLTRB(
                                          Styles.spacing16,
                                          0,
                                          Styles.spacing16,
                                          0),
                                      child: IntrinsicHeight(
                                        child: Row(
                                          children: [
                                            Container(
                                              color: this.dataSource[index]
                                                          ['waterType'] ==
                                                      1
                                                  ? Styles.RedLightColor2
                                                  : Styles.BlueColor2,
                                              width: 30.w,
                                              height: 60.h,
                                              child: Column(
                                                mainAxisAlignment:
                                                    MainAxisAlignment.center,
                                                children: [
                                                  index == 0
                                                      ? Container(
                                                          height: 24.h,
                                                        )
                                                      : Container(
                                                          color: Styles
                                                              .DetailColor20,
                                                          width: 1,
                                                          height: 23.h,
                                                        ),
                                                  Image.asset(
                                                    index == 0
                                                        ? 'assets/images/gou.png'
                                                        : 'assets/images/quan.png',
                                                    width: 12.w,
                                                    height: 12.h,
                                                    fit: BoxFit.contain,
                                                  ),
                                                  (index == 0 &&
                                                          this
                                                                  .dataSource
                                                                  .length >
                                                              1)
                                                      ? Container(
                                                          color: Styles
                                                              .GrayButtonColor,
                                                          width: 1,
                                                          height: 23.h,
                                                        )
                                                      : (index !=
                                                              dataSource
                                                                      .length -
                                                                  1
                                                          ? Container(
                                                              color: Styles
                                                                  .DetailColor20,
                                                              width: 1,
                                                              height: 24.h,
                                                            )
                                                          : Container(
                                                              height: 24.h,
                                                            ))
                                                ],
                                              ),
                                            ),
                                            Expanded(
                                                child: GestureDetector(
                                              onTap: () {
                                                if (dataSource[index]
                                                ['waterType'] ==
                                                    2) {
                                                  Get.toNamed(
                                                      RouteConfig
                                                          .productionRecordDetail,
                                                      arguments:
                                                      dataSource[index]
                                                      ['waterId']);
                                                } else if (dataSource[index]
                                                ['waterType'] ==
                                                    1) {
                                                  Get.toNamed(
                                                      RouteConfig
                                                          .addComponentQuality,
                                                      arguments:
                                                      dataSource[index]);
                                                } else {
                                                  if (dataSource[index][
                                                  'processWaterType'] ==
                                                      1) {
                                                    Get.toNamed(
                                                        RouteConfig
                                                            .warehousingDetail,
                                                        arguments: dataSource[
                                                        index]);
                                                  }else if(dataSource[index][
                                                  'processWaterType'] ==
                                                      2){
                                                    Get.toNamed(
                                                        RouteConfig
                                                            .moveLibraryDetail,
                                                        arguments: dataSource[
                                                        index]);

                                                  }else if(dataSource[index][
                                                  'processWaterType'] ==
                                                      3){
                                                    Get.toNamed(
                                                        RouteConfig
                                                            .transportDetail,
                                                        arguments: dataSource[
                                                        index]);

                                                  }else{
                                                    Get.toNamed(
                                                        RouteConfig
                                                            .returnsDetail,
                                                        arguments: dataSource[
                                                        index]);
                                                  }
                                                }
                                              },
                                              child: Container(
                                                padding: EdgeInsets.fromLTRB(
                                                    Styles.spacing16,
                                                    Styles.spacing8,
                                                    Styles.spacing16,
                                                    Styles.spacing8),
                                                color: Styles.WhiteGray,
                                                child: Row(
                                                  mainAxisAlignment:
                                                      MainAxisAlignment
                                                          .spaceBetween,
                                                  crossAxisAlignment:
                                                      CrossAxisAlignment.center,
                                                  children: [
                                                    Column(
                                                      crossAxisAlignment:
                                                          CrossAxisAlignment
                                                              .start,
                                                      children: [
                                                        Text(
                                                          this.dataSource[index]
                                                                      [
                                                                      'operateContent'] !=
                                                                  null
                                                              ? this.dataSource[
                                                                      index][
                                                                  'operateContent']
                                                              : '--',
                                                          style: TextStyle(
                                                              color: Styles
                                                                  .DetailColor,
                                                              fontSize: Styles
                                                                  .NormalFont),
                                                        ),
                                                        Text(
                                                          '${this.dataSource[index]['operator'] != null ? this.dataSource[index]['operator'] : ''} ${this.dataSource[index]['create'] != null ? Utils.formatDateTimeToMinute(this.dataSource[index]['create']) : '--'}',
                                                          style: TextStyle(
                                                              color: Styles
                                                                  .LeftTitleColor,
                                                              fontSize: Styles
                                                                  .SmallFont),
                                                        )
                                                      ],
                                                    ),
                                                    dataSource[index]
                                                                ['waterId'] !=
                                                            null
                                                        ? Image.asset(
                                                            'assets/images/right_arrow.png',
                                                            width: 14.w,
                                                            height: 14.w,
                                                            fit: BoxFit.contain,
                                                            color: Styles
                                                                .LeftTitleColor,
                                                          )
                                                        : Container()
                                                  ],
                                                ),
                                              ),
                                            ))
                                          ],
                                        ),
                                      ),
                                    );
                                  }).toList(),
                                ),
                              ),
                            ],
                          )
                        : Column(
                            children: this.BOMList.map((e) {
                              return Container(
                                alignment: Alignment.centerLeft,
                                decoration: BoxDecoration(
                                    border: Border(
                                        bottom: BorderSide(
                                            color: Styles.LineColor,
                                            width: 1))),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Container(
                                      padding: EdgeInsets.fromLTRB(
                                          Styles.spacing8,
                                          Styles.spacing8,
                                          Styles.spacing8,
                                          Styles.spacing4),
                                      child: Text(
                                        "材料名称 ${e['name']}",
                                        style: TextStyle(
                                            color: Styles.DetailColor,
                                            fontSize: Styles.NormalFont),
                                      ),
                                    ),
                                    Container(
                                      padding: EdgeInsets.fromLTRB(
                                          Styles.spacing8,
                                          Styles.spacing4,
                                          Styles.spacing8,
                                          Styles.spacing4),
                                      child: Text(
                                        "数量 ${e['quantity'].toString()}",
                                        style: TextStyle(
                                            color: Styles.DetailColor,
                                            fontSize: Styles.NormalFont),
                                      ),
                                    ),
                                  ],
                                ),
                              );
                            }).toList(),
                          ),
                  ],
                ),
              ),
            ),
            GestureDetector(
              onTap: () {
                Get.toNamed(RouteConfig.addProductionRecord,
                    arguments: {'compDetail': compDetail, 'flow': dataSource});
              },
              child: Container(
                margin: EdgeInsets.fromLTRB(Styles.spacing32, Styles.spacing8,
                    Styles.spacing32, Styles.spacing8),
                decoration: new BoxDecoration(
                  //背景
                  color: Styles.BlueColor,
                  //设置四周圆角 角度
                  borderRadius: BorderRadius.all(Radius.circular(12.0)),
                ),
                child: Container(
                  height: Styles.MainButtonHeight,
                  alignment: Alignment.center,
                  child: Text(
                    '添加生产记录',
                    style: TextStyle(
                        fontSize: Styles.MainButtonTextFont,
                        color: Colors.white),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
      floatingActionButtonLocation: CustomFloatingActionButtonLocation(
          FloatingActionButtonLocation.endFloat),
      floatingActionButtonAnimator: NoScalingAnimation(),
      floatingActionButton: FloatingActionButton(
          child: Image.asset(
            'assets/images/saoyisao.png',
            fit: BoxFit.contain,
          ),
          onPressed: () async {
            var result = await QrScan.scan(context);
            if (result != null) {
              if (result['type'] == 1) {
                Get.offAndToNamed(RouteConfig.productionDetail,
                    arguments: result['code']);
              } else {
                showDialog(
                    barrierDismissible: false,
                    context: context,
                    builder: (BuildContext context) {
                      return AlertDialog(
                        title: Text('注意'),
                        content: Text('请扫描构件二维码！'),
                        actions: <Widget>[
                          new Container(
                            child: FlatButton(
                              child: new Text(
                                "确定",
                                style: TextStyle(color: Colors.red),
                              ),
                              onPressed: () {
                                Navigator.pop(context);
                              },
                            ),
                          ),
                        ],
                      );
                    });
              }
            }
          },
          backgroundColor: Colors.transparent),
    );
  }
}
